/**
 * @file snippet/dp/longest_increasing_sequence/main
 * @brief 导弹拦截 最长上升子序列 最长不下降子序列
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 5/18/2022 20:53:37
 **/

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int N = 100010;
int a[N], n;
int d1[N], d2[N];
int main() {
  // High rating and good luck!
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  n = 1;
  while (cin >> a[n]) n++;
  n--;
  int len1 = 1, len2 = 1;
  d1[1] = d2[1] = a[1];
  for (int i = 2; i <= n; ++i) {
    if (d1[len1] >= a[i])
      d1[++len1] = a[i];
    else
      *upper_bound(d1 + 1, d1 + 1 + len1, a[i], greater<>()) = a[i];
    if (d2[len2] < a[i])
      d2[++len2] = a[i];
    else
      *lower_bound(d2 + 1, d2 + 1 + len2, a[i]) = a[i];
  }
  cout << len1 << endl << len2 << endl;
  return 0;
}
